use std::sync::Arc;

use anyhow::Result;
use bytes::BytesMut;

use crate::proxy_config::ProxyConfig;
pub trait Proxy {
    ///启动服务，socks：启动监听，ethan：启动监听，freedom：？？
    async fn start_serve(&mut self) -> Result<()>;
    ///服务准备，flag：为inbound、outbound的标识，inbound：01，outbound：02
    async fn prepare_serve(config: Arc<ProxyConfig>, flag: InOutBound) -> Result<Self>
    where
        Self: Sized;
}
#[derive(Debug, PartialEq)]
pub enum InOutBound {
    InBound,
    OutBound,
}

pub trait InBoundProxy {
    ///服务准备，flag：为inbound、outbound的标识，inbound：01，outbound：02
    async fn prepare_serve(config: Arc<ProxyConfig>, flag: InOutBound) -> Result<Self>
    where
        Self: Sized;
    ///启动服务，socks：启动监听，ethan：启动监听，freedom：？？
    async fn start_serve(&mut self) -> Result<()>;
    async fn auth(&mut self)->Result<()>;
}
pub trait OutBoundProxy {
    ///预连接服务端
    async fn prepare_serve(config:Arc<ProxyConfig>)->Result<()>;
    ///传输数据
    async fn trans_data(&mut self, data: BytesMut) -> Result<()>;
}
